package com.ym.controller.management;

import com.github.pagehelper.PageInfo;
import com.ym.core.domain.APIResponse;
import com.ym.core.domain.BaseController;
import com.ym.medical.domain.entity.SysHelpEntity;
import com.ym.medical.domain.param.SysHelpParam;
import com.ym.medical.service.IConfSV;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 综合管理中心
 */
@Api(tags = "配置管理")
@RestController
@RequestMapping("/management/conf")
public class ConfManagement extends BaseController {

	@Autowired
	private IConfSV confSV;

	@ApiOperation("帮助与反馈新增")
	@PostMapping("/sysHelp/add")
	public APIResponse<SysHelpEntity> insertSysHelp(
			@ApiParam(name = "sysHelp", value = "帮助与反馈实体", required = true)
			@Validated(value = {SysHelpParam.Add.class}) @RequestBody SysHelpParam sysHelp) {
		SysHelpEntity sysHelp1 = confSV.insertSysHelp(sysHelp.covert());
		return APIResponse.success("帮助与反馈新增成功", sysHelp1);
	}

	@ApiOperation("帮助与反馈修改")
	@PostMapping("/sysHelp/update")
	public APIResponse<SysHelpEntity> updateSysHelp(
			@ApiParam(name = "sysHelp", value = "帮助与反馈实体", required = true)
			@Validated(value = {SysHelpParam.Update.class})
			@RequestBody SysHelpParam sysHelp) {
		SysHelpEntity sysHelp1 = confSV.updateSysHelp(sysHelp);
		return APIResponse.success("帮助与反馈修改成功", sysHelp1);
	}

	@ApiOperation("帮助与反馈删除")
	@PostMapping("/sysHelp/delete")
	public APIResponse deleteSysHelp(@ApiParam(name = "ids", value = "帮助与反馈实体id", required = true) @RequestBody Long[] ids) {
		confSV.deleteSysHelp(ids);
		return successMsg("帮助与反馈删除成功!");
	}

	@ApiOperation("帮助与反馈发布")
	@PostMapping("/sysHelp/publish")
	public APIResponse publishSysHelp(@ApiParam(name = "id", value = "帮助与反馈实体id", required = true) @RequestBody List<Long> ids) {
		confSV.publishSysHelp(ids);
		return successMsg("帮助与反馈发布成功");

	}

	@ApiOperation("帮助与反馈撤回")
	@PostMapping("/sysHelp/recall")
	public APIResponse recallSysHelp(@ApiParam(name = "id", value = "帮助与反馈实体id", required = true) @RequestBody List<Long> ids) {
		confSV.recallSysHelp(ids);
		return successMsg("帮助与反馈撤回成功");
	}

	@ApiOperation("帮助与反馈展示")
	@GetMapping("/sysHelp/list")
	public APIResponse<PageInfo<SysHelpEntity>> listSysHelp(@ApiParam(name = "sysHelp", value = "帮助与反馈实体", required = true) SysHelpParam sysHelp,
                                                      @RequestParam(required = false, defaultValue = "1") int pageNo,
                                                      @RequestParam(required = false, defaultValue = "10") int limit) {
		PageInfo<SysHelpEntity> info = confSV.listSysHelp(sysHelp, pageNo, limit);
		return APIResponse.success("帮助与反馈展示成功", info);
	}


}
